package db.migrations;

import static com.eroi.migrate.Define.autoincrement;
import static com.eroi.migrate.Define.column;
import static com.eroi.migrate.Define.defaultValue;
import static com.eroi.migrate.Define.length;
import static com.eroi.migrate.Define.notnull;
import static com.eroi.migrate.Define.primarykey;
import static com.eroi.migrate.Define.table;
import static com.eroi.migrate.Define.uniqueIndex;
import static com.eroi.migrate.Define.DataTypes.BOOLEAN;
import static com.eroi.migrate.Define.DataTypes.INTEGER;
import static com.eroi.migrate.Define.DataTypes.LONGVARCHAR;
import static com.eroi.migrate.Define.DataTypes.NUMERIC;
import static com.eroi.migrate.Define.DataTypes.TIMESTAMP;
import static com.eroi.migrate.Define.DataTypes.TINYINT;
import static com.eroi.migrate.Define.DataTypes.VARCHAR;
import static com.eroi.migrate.Execute.addIndex;
import static com.eroi.migrate.Execute.createTable;
import static com.eroi.migrate.Execute.dropIndex;
import static com.eroi.migrate.Execute.dropTable;

import org.apache.log4j.Logger;

import com.eroi.migrate.Define.Length;
import com.eroi.migrate.Define.PrimaryKey;
import com.eroi.migrate.Migration;
import com.eroi.migrate.mchema.Column;

/**
 * 
 * Person
 * @author gongfu
 *
 */
public class Migration_3 implements Migration{

	private static final Logger logger  = Logger.getLogger(Migration_3.class);
	
	private final String T_G_S = "gf_sort";
	
	public void up(){
		logger.info("Migration_3_gf.up--------------------->");
		createTable(
				table(T_G_S, 
						column("id", INTEGER, "", primarykey(), notnull(), autoincrement()),
						column("pid", INTEGER, "父级id", notnull()),
						column("name", VARCHAR, "名称", length(40)),
						column("isable", TINYINT, "是否启用", defaultValue(1)),
						column("order_by", INTEGER, "序号", defaultValue(0))
				)
		);
	}
	
	public void down(){
		logger.info("Migration_3_gf.down--------------------->");
		dropTable(T_G_S);
	}
}
